<?php
require_once('includeDb.php');

error_reporting(E_ALL);
ini_set("display_errors", 1);

function getBooks()
{
    global $language1;
    global $language2;
    //   echo "hi";
    $bibleBookNamesDAO = DAOFactory::getBibleBookNamesDAO();

    $arr = $bibleBookNamesDAO->queryByLanguage('ti');
    $x = '<ul id="navigation" class="navigation">';
    $x .= '<li class="closed"><span class="folder">old testament</span><ul>';
    $y =  '<li class="closed expandable"><span class="folder">new testament</span><ul>';
    $z = '</ul></li>';

    for ($i = 0; $i < 39; $i++) {
        $row = $arr[$i];
        $x .= '<li><span class="file">' . $row->middleName;
        $x .= "</span>\n\t\t";
        $x .= getPart($row);
    }

    for ($i = 39; $i < count($arr); $i++) {
        $row = $arr[$i];
        $y .= '<li><a href="#">' . $row->middleName;
        $y .= "</a>\n\t\t";
        $y .= getPart($row);
    }

    $x .= $z . $y . $z. '</ul>';

    return $x;

}

function getPart(BibleBookName $b)
{
    $x = '<ul id="folder21">';
    $i = 1;
    while ($i <= $b->chapterSize) {
        $x .= '<li><a href="index.php?book='.$b->bookNo.'&chapter='.$i.'">Chapter ' . $i;
        $x .= "</a></li>";
        $i++;
    }
    $x .= "</ul>";
    return $x;
}

?>